package cz.muni.fi.pa036is.servicesimplementation;

import cz.muni.fi.pa036is.daointerface.CommentDAO;
import cz.muni.fi.pa036is.daointerface.MatchDAO;
import cz.muni.fi.pa036is.daointerface.PersonDAO;
import cz.muni.fi.pa036is.dto.CommentFormTO;
import cz.muni.fi.pa036is.dto.CommentGridTO;
import cz.muni.fi.pa036is.dtoconverters.CommentConverter;
import cz.muni.fi.pa036is.entity.Comment;
import cz.muni.fi.pa036is.servicesinterface.CommentService;
import cz.muni.fi.pa036is.utilities.TimeService;
import java.util.List;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

/**
 *
 * @author Shebik
 */
@Service
public class CommentServiceImpl implements CommentService {

    @Autowired
    private CommentDAO commentDAO;

    @Override
    public void addComment(final CommentFormTO commentFormTO) {
        final Comment comment = CommentConverter.convertToComment(commentFormTO);
        comment.setDate(TimeService.getCurrentTimestamp());
        commentDAO.addComment(comment);
    }

    @Override
    public void deleteComment(final Long id) {
        commentDAO.deleteComment(id);
    }

    @Override
    public List<CommentGridTO> getAllCommentsForMatch(final Long matchId) {
        return CommentConverter.convertToCommentGridTOList(
                commentDAO.getAllCommentsForMatch(matchId));
    }

}
